package com.huike.service.system.impl;

import com.github.pagehelper.PageHelper;
import com.huike.dto.SysDictNormalDTO;
import com.huike.dto.SysDictPageQueryDTO;
import com.huike.mapper.system.SysDictMapper;
import com.huike.result.Result;
import com.huike.service.system.SysDictService;
import com.huike.vo.DictPageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDictServiceImpl implements SysDictService {
    @Autowired
    private SysDictMapper dictMapper;
    @Override
    public Result<List<DictPageVO>> list(SysDictPageQueryDTO queryDTO) {
        if (null == queryDTO){
            return Result.error("参数不能为空");
        }
        List<DictPageVO> list = dictMapper.selectDictList(queryDTO);
        PageHelper.startPage(queryDTO.getPageNum(),queryDTO.getPageSize());
        Result<Object> objectResult = new Result<>();
        objectResult.setMsg("查询成功");
        objectResult.setData(list);
        objectResult.setCode(200);
        return  Result.success(list);
    }

    @Override
    public Result<List<SysDictNormalDTO>> listNormalDisable() {
        List<SysDictNormalDTO> sysDictNormalDTOS = dictMapper.selectNormalDisable();
        Result<List<SysDictNormalDTO>> objectResult = new Result<>();
        objectResult.setData(sysDictNormalDTOS);
        objectResult.setCode(200);
        objectResult.setMsg("查询成功");
        return objectResult;
    }
}
